@echo off
REM DDM MSVC构建脚本

echo 正在检测Qt安装路径...

REM 检查常见的Qt安装路径
set QT_PATH=
if exist "C:\Qt\6.9.1\msvc2022_64" (
    set QT_PATH=C:\Qt\6.9.1\msvc2022_64
) else if exist "C:\Qt\6.8.0\msvc2022_64" (
    set QT_PATH=C:\Qt\6.8.0\msvc2022_64
) else if exist "C:\Qt\6.7.0\msvc2022_64" (
    set QT_PATH=C:\Qt\6.7.0\msvc2022_64
) else (
    echo 未找到Qt安装路径，请确保Qt6已正确安装
    echo 请从 https://www.qt.io/download 下载并安装Qt6
    pause
    exit /b 1
)

echo 使用Qt路径: %QT_PATH%

if not exist build mkdir build
cd build

echo 正在配置项目...
cmake .. -G "Visual Studio 17 2022" -DCMAKE_PREFIX_PATH="%QT_PATH%"

if %errorlevel% neq 0 (
    echo CMake配置失败
    cd ..
    pause
    exit /b %errorlevel%
)

echo 正在构建项目...
cmake --build . --config Release

if %errorlevel% neq 0 (
    echo 构建失败
    cd ..
    pause
    exit /b %errorlevel%
)

echo 构建完成!
cd ..